package com.example.tse.rbyair;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.example.tse.rbhttpservice.service.RemoteServiceFactory;
import com.example.tse.rbhttpservice.service.RemoteServiceListenerT;
import com.example.tse.rbhttpservice.service.member.model.MemberSettingCheckVersionRequest;
import com.example.tse.rbhttpservice.service.member.model.MemberSettingCheckVersionResponse;
import com.example.tse.rbyair.util.AppInforUtil;

import org.kymjs.kjframe.log.L;
import org.kymjs.kjframe.utils.SystemTool;


public class WelcomeActivity extends FragmentActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        L.d("WelcomeActivity onCreate:");

        setContentView(R.layout.main_wlecome_activity);

        getAppVersion();

    }


    private void getAppVersion() {
        MemberSettingCheckVersionRequest r = new MemberSettingCheckVersionRequest() {
            @Override
            public String giveVersion() {
                return "";
            }
        };
        RemoteServiceFactory.getInstance().getMemberSettingService(getApplicationContext()).checkVersion(r, new RemoteServiceListenerT<MemberSettingCheckVersionResponse>() {


            @Override
            public void PreStart() {
                super.PreStart();
            }

            @Override
            public void okData(MemberSettingCheckVersionResponse memberSettingCheckVersionResponse) {
                super.okData(memberSettingCheckVersionResponse);


                AppInforUtil.LastestVersion = Integer.parseInt(memberSettingCheckVersionResponse.getLastestVersion());
                AppInforUtil.MinAndroidVersion = Integer.parseInt(memberSettingCheckVersionResponse.getMinAndroidVersion());
                AppInforUtil.AppVersionCode = SystemTool.getAppVersionCode(WelcomeActivity.this);
                AppInforUtil.AndroidUrl = memberSettingCheckVersionResponse.getAndroidUrl();


            }


            @Override
            public void failue(int errorCode, String errorMessage) {
                L.d("WelcomeActivity getAppVersion errorMessage:" + errorMessage);
            }

            @Override
            public void Finish() {
                super.Finish();
            }
        });
    }


}

